package utils;

import org.hibernate.*;
import org.hibernate.cfg.*;

public class HibernateUtil {
	
	private static final SessionFactory sessionFactory;

	static {
		try {
			sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
		} 
		catch (Throwable ex) {
			throw new ExceptionInInitializerError(ex);
		}
	}

	public static Session getCurrentSession() {
		return sessionFactory.getCurrentSession();
	}
	
	public static Session getNewSession() {
		return sessionFactory.openSession();
	}
}
